<?php if (!defined('THINK_PATH')) exit(); /*a:4:{s:75:"C:\wwwroot\vipwaimai.com\web/../application/admin\view\seller\category.html";i:1508554218;s:73:"C:\wwwroot\vipwaimai.com\web/../application/admin\view\public\header.html";i:1503189484;s:71:"C:\wwwroot\vipwaimai.com\web/../application/admin\view\public\city.html";i:1510310973;s:73:"C:\wwwroot\vipwaimai.com\web/../application/admin\view\public\footer.html";i:1512624954;}*/ ?>
﻿<!DOCTYPE html>
<html lang="zh-cn">

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<meta name="renderer" content="webkit">
		<title><?php echo config('sitename'); ?>-<?php echo lang('label')['Login_title']; ?></title>
		<link rel="stylesheet" type="text/css" href="__ROOT__/static/public/css/pintuer.css" />
		<link rel="stylesheet" type="text/css" href="__ROOT__/static/admin/css/admin.css" />
		<script type="text/javascript" src="__ROOT__/static/public/js/jquery.js"></script>
		<script type="text/javascript" src="__ROOT__/static/public/js/pintuer.js"></script>
		<script type="text/javascript" src="__ROOT__/static/admin/js/admin.js"></script>
		<script type="text/javascript" src="__ROOT__/static/public/layer/layer.js"></script>
		<script type="text/javascript" src="__ROOT__/static/public/laydate/laydate.js"></script>
		<script type="text/javascript" src="__ROOT__/static/public/laytpl/laytpl.js"></script>
	</head>

	<body>
	<style>
		html { overflow-x:hidden; }
	</style>
<form method="post" class="padding">
    <div class="panel admin-panel">
        <div class="panel-head"><strong><?php echo lang('currency')['edit']; ?><?php echo lang('label')['category']; ?></strong></div>
        <div class="padding border-bottom">
            <a type="button" class="button button border-green addcat" href="#"/><?php echo lang('currency')['add']; ?><?php echo lang('label')['category']; ?></a>
            <script>
                //city 参数和回调
                var pid="<?php echo input('get.pid'); ?>";
                var cid="<?php echo input('get.cid'); ?>";
                var aid="<?php echo input('get.aid'); ?>";
                var selectc = true;
                var selecta = true;
                function select_p(){
                    return false;
                }
                function select_c(){
                    return false;
                }
                function select_a(){
                    location.href="?pid="+pid+"&cid="+cid+"&aid="+aid;
                }
            </script>
            <?php echo lang('label')['select']; ?><?php echo lang('currency')['city']; ?>:<?php if(input('session.type') == 'province' || input('session.type') == 'all'): ?>
<select id="province" onchange="pchange(this.value)" name="pid" class="input input-auto" >
	<option value="">请选择</option>
</select>
<?php endif; if(input('session.type') == 'province' ||  input('session.type') == 'city' || input('session.type') == 'all'): ?>
<select id="city" onchange="cchange(this.value)" name="cid" class="input input-auto hidden" >
	<option value="">请选择</option>
</select>
<?php endif; ?>
<select id="area" onchange="achange(this.value)" name="aid" class="input input-auto hidden" >
	<option value="">请选择</option>
</select>
<script id="province_list_tpl" type="text/html">
	{{# for(var i = 0, len = d.data.length; i < len; i++){ }}
	<option {{# if(d.data[i].id==pid){ }}selected{{#}}} value="{{ d.data[i].id }}">{{ d.data[i].name }}</option>
	{{# } }}
</script>
<script id="city_list_tpl" type="text/html">
	{{# for(var i = 0, len = d.data.length; i < len; i++){ }}
	<option {{# if(d.data[i].id==cid){ }}selected{{#}}} value="{{ d.data[i].id }}">{{ d.data[i].name }}</option>
	{{# } }}
</script>
<script id="area_list_tpl" type="text/html">
	{{# for(var i = 0, len = d.data.length; i < len; i++){ }}
	<option {{# if(d.data[i].id==aid){ }}selected{{#}}} value="{{ d.data[i].id }}">{{ d.data[i].name }}</option>
	{{# } }}
</script>
<script>
    var func = false;
    $('select').click(function(){
        func = true;
    });
    if(selectc) {
        $('[name=cid]').removeClass('hidden');
    }
    if(selecta){
        $('[name=aid]').removeClass('hidden');
    }
    if('<?php echo input("session.type"); ?>' == 'province' || '<?php echo input("session.type"); ?>' == 'all') {
        $.getJSON('__ROOT__/admin/city/ajax_get?type=province', {}, function (res) {
            var tpl = $("#province_list_tpl").html();
            laytpl(tpl).render(res, function (render) {
                $("#province").html('<option value="">请选择</option>' + render);
            });
            if (pid != '' && pid != 0) {
                $('[name=pid]').change();
            }
        });
    }else if('<?php echo input("session.type"); ?>' == 'city'){
        val = '<?php echo input("session.aid"); ?>';
        if(selectc){
            $.getJSON('__ROOT__/admin/city/ajax_get?type=city&id='+val, {}, function(res){
                var tpl = $("#city_list_tpl").html();
                laytpl(tpl).render(res, function(render){
                    $("#city").html('<option value="">请选择</option>' + render);
                    $("#city").val(cid);
                    $("#city").change();
                });
            });
        }
    }else if('<?php echo input("session.type"); ?>' == 'area'){
        val = '<?php echo input("session.aid"); ?>';
        //if(selecta && aid){
            $.getJSON('__ROOT__/admin/city/ajax_get?type=area&nofather=ok&id='+val, {}, function(res){
                var tpl = $("#area_list_tpl").html();
                laytpl(tpl).render(res, function(render){
                    $("#area").html('<option value="">请选择</option>'+render);
                });
            });
       // }
    }
    function pchange(val) {
        pid = val;
        if(selectc){
            $.getJSON('__ROOT__/admin/city/ajax_get?type=city&id='+pid, {}, function(res){
                var tpl = $("#city_list_tpl").html();
                laytpl(tpl).render(res, function(render){
                    $("#city").html('<option value="">请选择</option>'+render);
                });
                if(selectc == true){
                    if(cid != '' && cid != 0){
                        $('[name=cid]').change();
                    }
                }
            });
        }
        if(func){
            select_p();
        }
    }
    function cchange(val) {
        cid = val;
        if(selecta && cid){
            $.getJSON('__ROOT__/admin/city/ajax_get?type=area&id='+cid, {}, function(res){
                var tpl = $("#area_list_tpl").html();
                laytpl(tpl).render(res, function(render){
                    $("#area").html('<option value="">请选择</option>'+render);
                });
            });
        }
        if(func){
            select_c();
        }
    }
    function achange(val) {
        aid = val;
        $('[name=aid]').removeClass('hidden');
        if(func){
            select_a();
        }
    }
</script>
        </div>
        <table class="table table-hover">
            <tr>
                <th width="100"><?php echo lang('label')['image']; ?></th>
                <th width="100"><?php echo lang('label')['title']; ?></th>
                <th width="100"><?php echo lang('label')['handle']; ?></th>
            </tr>
            <?php if(is_array($data) || $data instanceof \think\Collection || $data instanceof \think\Paginator): $i = 0; $__LIST__ = $data;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$volist): $mod = ($i % 2 );++$i;?>
            <tr>
                <td style="line-height:40px"><input readonly id="scimage<?php echo $volist['title']; ?>" data-id="<?php echo $volist['id']; ?>" type="text" class="hidden">
                <img data-id="scimage<?php echo $volist['title']; ?>" style="width: 40px;height: 40px" src="<?php echo $volist['image']; ?>"/></td>
                <td style="line-height:40px"><strong><?php echo $volist['title']; ?></strong></td>
                <td style="line-height:40px"><a class="button border-blue button-little editcat" data-id="<?php echo $volist['id']; ?>"><?php echo lang('currency')['edit']; ?></a>
                    <a class="button border-yellow button-little delcat" data-id="<?php echo $volist['id']; ?>"><?php echo lang('currency')['del']; ?></a>
                </td>
            </tr>
            <?php endforeach; endif; else: echo "" ;endif; ?>
        </table>
    </div>
</form>
<script>
    layer.config({
        extend: 'extend/layer.ext.js'
    });
    $('.flagcat').click(function () {
        var mythis = $(this)
        var str = mythis.attr('data-id');
        var id = str.split("&")[0];
        var flag = str.split("&")[1];
//                $.getJSON("__URL__/category_flag.html?id="+id+"&flag="+flag,function(data){
//                    if(data.code == 'success'){
//                        msg(data.msg,1);
//                        location.reload();
//                    }
//                });
        layer.open({
            type: 2,
            title: '',
//                    shade:false,
//                    skin: 'layui-layer-rim', //加上边框
            area: ['350px', '260px'], //宽高
            content: '__URL__/flag_edit.html?id=' + id
        });
    })
    $('.delcat').click(function () {
        var mythis = $(this)
        var id = mythis.attr('data-id');
        layer.confirm("确定要删除吗？（请确保此分类下无商家，否则可能会导致数据异常！）", {
            btn: ["<?php echo lang('currency')['status_1']; ?>", "<?php echo lang('currency')['status_2']; ?>"] //按钮
        }, function () {
            $.getJSON("__URL__/category_del.html?id=" + id, function (data) {
                if (data.code == 'success') {
                    msg(data.msg, 1);
                    location.reload();
                }
            });
        });
    });
    $('.addcat').click(function () {
        layer.open({
            type: 2,
            title: '',
//					shade:false,
//                    skin: 'layui-layer-rim', //加上边框
            area: ['400px', '330px'], //宽高
            content: '__URL__/category_edit.html'
        });
    });
    $('.addcatsub').click(function () {
        var mythis = $(this)
        var gid = mythis.attr('data-id');
        layer.open({
            type: 2,
            title: '',
//                    shade:false,
//                    skin: 'layui-layer-rim', //加上边框
            area: ['350px', '260px'], //宽高
            content: '__URL__/category_edit.html?gid=' + gid
        });
    });
    $('.editcat').click(function () {
        var mythis = $(this)
        var id = mythis.attr('data-id');
//				layer.prompt({title:'<?php echo lang('currency')['edit']; ?><?php echo lang('label')['category']; ?>'},function(val){
//					$.post("__ROOT__/admin/service/category_edit.html?id="+id,{title:val},function(data){
//						if(data.code == 'success'){
//							msg(data.msg,1);
//							location.reload();
//						}
//					});
//				});
        layer.open({
            type: 2,
            title: '',
//                    shade:false,
//                    skin: 'layui-layer-rim', //加上边框
            area: ['400px', '330px'], //宽高
            content: '__URL__/category_edit.html?id=' + id
        });
    });
    function uploadfunc(id) {
        var url = $("#" + id).val();
        var dataid = $("#" + id).attr('data-id');
        $("#" + id).parent().find('img').attr('src', url);
        $.post("__URL__/category_edit.html?id=" + dataid, {image: url}, function (data) {
            if (data.code == 'success') {
                msg(data.msg, 1);
            }
        });
    }
</script>
<p class="text-center text-gray" style="margin-top:10px;"><a class="text-gray" target="_blank" href="http://www.wm0530.com">完美外卖系统 Power by 网络工厂</a></p>
</body>
<script>
$('.upload').on('click',function (){
		var id = $(this).attr('data-id');
		 upload(id);
	}
);
function upload(id){
	layer.open({
		type:2,
		title:false,
		area: ['70%', '90%'],
		offset: '5%',
		content: "<?php echo url('/admin/material'); ?>?id="+id
	});
}
</script>
</html>